<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"> 
    
    <h:body>
        <ui:composition template="../template.xhtml">

            <ui:define name="content">
            
				<p:dataGrid var="item" value="#{packetFrontend.list}" columns="1"  
			        rows="5" paginator="true"  
			        paginatorTemplate="{CurrentPageReport}  {PreviousPageLink} {PageLinks} {NextPageLink}  "  
			        >  
			  
			        <p:panel header="#{item.packet.name}" style="text-align:center">  
			            <h:panelGrid columns="1" style="width:100%;text-aling:left;">  
			            
			                <h:outputText value="#{item.packet.place.name}" />  
			                <h:outputText value="#{item.packet.description}" />
			                
			                <ul>
			                	<ui:repeat value="#{item.packet.products}" var="p">
			                	<li>
			                		<h:panelGroup layout="block"  rendered="#{p.excursion!=null}">
									    <b>Escursione:</b> 
									    #{p.excursion.name} 
						            	<h:outputText value="#{excursion.date}">
										    <f:convertDateTime pattern="dd/MM/yyyy" type="date" />
										</h:outputText>
										- 
										#{p.price} &euro;
					            	</h:panelGroup> 
					            	
					            	<h:panelGroup layout="block"  rendered="#{p.hotel!=null}">
									    <b>Hotel:</b> 
									    #{p.hotel.name} (#{p.hotel.stars} stelle) - 
									    dal
						            	<h:outputText value="#{p.hotel.checkInDate}">
										    <f:convertDateTime pattern="dd/MM/yyyy" type="date" />
										</h:outputText>
										al
						            	<h:outputText value="#{p.hotel.checkOutDate}">
										    <f:convertDateTime pattern="dd/MM/yyyy" type="date" />
										</h:outputText>
										- 
										#{p.price} &euro;
					            	</h:panelGroup> 
					            	
					            	<h:panelGroup layout="block"  rendered="#{p.flight!=null}">
									    <b>Volo:</b> 
									    Da 
						                #{p.flight.place.name} - 
						            	<h:outputText value="#{p.flight.departureDate}">
										    <f:convertDateTime pattern="dd/MM/yyyy" type="date" />
										</h:outputText>
						                 
										a
						                #{p.place.name} - 
						            	<h:outputText value="#{p.flight.arrivalDate}">
										    <f:convertDateTime pattern="dd/MM/yyyy" type="date" />
										</h:outputText>
										-
										#{p.price} &euro;
					            	</h:panelGroup> 
			                	</li>
			                	</ui:repeat>
				                <li><b>Prezzo Totale:</b> #{item.price}</li>
								<h:panelGroup layout="block"  rendered="#{item.discount>0}">
									   <li><b>Prezzo scontato:</b> #{item.discountedPrice}</li>
			  					</h:panelGroup>
			                </ul>
			                
			                <p:commandButton value="Prenota" action="#{packetFrontend.selectAction(item.packet.id)}" >  
			                </p:commandButton>  
			            </h:panelGrid>  
			        </p:panel>  
			  
			    </p:dataGrid>  
			    
	
			</ui:define>
        </ui:composition>
    </h:body>
</html>
